using System;
using System.Collections.Generic;
using System.Dynamic;
using RimWorld;
using Verse;
using Verse.AI;

namespace RimZombieGirl
{
    // 参考 JobDriver_SuppressSlave
    public class WorkGiver_Warden_SuppressZombie : WorkGiver_Warden
    {
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            if (!MapHasControlledZombies(pawn.Map))
            {
                return null;
            }

            Pawn targetPawn = t as Pawn;

            // 如果需要压制
            Need_Zombie_Suppress need = null;
            targetPawn?.needs?.TryGetNeed(out need);
            if (need == null || !need.ShouldSuppress)
            {
                return null;
            }

            return JobMaker.MakeJob(ZombieDefOf.RI_Zombie_Suppress, t);
        }

        private bool MapHasControlledZombies(Map map)
        {
            if (map == null)
            {
                return false;
            }
            // return map.mapPawns.AllPawnsSpawned.Any(pawn => pawn.IsZombie() && pawn.Faction == Faction.OfPlayer);
            return false;
        }
    }
}